﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Create.Master" Inherits="System.Web.Mvc.ViewPage<Langben.DAL.Cemetery>" %>

<%@ Import Namespace="Common" %>
<%@ Import Namespace="Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CurentPlace" runat="server">
    墓穴管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="panel datagrid" style="width: auto;">
        <div class="panel-header">
            <div>
                选择园区： 
        <%=Html.DropDownListFor(model => model.Yuan,Models.SysFieldModels.GetArea("Area","Yuan"),"请选择")%>
                <select id="Pian" name="Pian">
                </select>
                <select id="Qu" name="Qu">
                </select>
            </div>
        </div>


    </div>

     <div class="panel-body" style="height: 100%;">
            <div style="padding: 10px">
                 
                <div class="bigdiv" style="display: none">
                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.QuGuid) %>：
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.QuGuid) %>
                        <%: Html.ValidationMessageFor(model => model.QuGuid) %>
                    </div>
                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.Hao) %>：
                    </div>
                    <div class="editor-field">
                        <%: Html.TextBoxFor(model => model.Hao, new {  onkeyup = "isInt(this)", @class="text-box single-line" })%>
                        <%: Html.ValidationMessageFor(model => model.Hao) %>
                    </div>
                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.Pai) %>：
                    </div>
                    <div class="editor-field">
                        <%: Html.TextBoxFor(model => model.Pai, new {  onkeyup = "isInt(this)", @class="text-box single-line" })%>
                        <%: Html.ValidationMessageFor(model => model.Pai) %>
                    </div>
                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.ShapeGuid) %>：
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.ShapeGuid) %>
                        <%: Html.ValidationMessageFor(model => model.ShapeGuid) %>
                    </div>
                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.Price) %>：
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.Price) %>
                        <%: Html.ValidationMessageFor(model => model.Price) %>
                    </div>
                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.IsYanShou) %>：
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.IsYanShou) %>
                        <%: Html.ValidationMessageFor(model => model.IsYanShou) %>
                    </div>
                </div>
                <div id="CemeteryStr">
                </div>

            </div>
        </div>

    </div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <style>
        ul {
            clear: both;
        }

        li {
            float: left;
            list-style-type: none;
            width: 60px;
            text-align: center;
            height: 90px;
        }
    </style>
    <script type="text/javascript">

        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        $(function () {
            getPian("#Pian");
            $("#Yuan").change(function () { getPian("#Pian"); });

            getQu("#Qu");
            $("#Pian").change(function () { getQu("#Qu"); });

            $("#Qu").change(function () {
                $("#QuGuid").val($("#Qu").val());

                GetCemeteryString();
            });
            var aaa = getQueryString('isdanmu');
            //是弹幕定价过来的。
            if (aaa == "1") {
                $('#btnGroup').html('<a href="#" class="easyui-linkbutton l-btn" data-options="iconCls:\'icon-add\'" id="addCemetery" onclick="danmudingjia()"><span class="l-btn-left"><span class="l-btn-text icon-add l-btn-icon-left">单墓定价</span></span></a>');
            } else {
                var iframeid = window.parent.$('#tabs').tabs('getSelected').find('iframe').attr("id");
                $.getJSON("../Home/GetToolbar", { id: iframeid }, function (data) {
                    if (data == null) {
                        return;
                    } else {
                        $.each(data, function (i, item) {
                            var btnstr = '<a href="#" class="easyui-linkbutton l-btn" data-options="iconCls:\'' + item.iconCls + '\'" id="addCemetery" onclick="' + item.handler + '()"><span class="l-btn-left"><span class="l-btn-text icon-add l-btn-icon-left">' + item.text + '</span></span></a>';
                            $('#btnGroup').html($('#btnGroup').html() + btnstr);
                        });
                    }
                });
            }
            
           
        });
        function getPian(Pian) {
            $(Pian).empty();
            $("<option></option>")
                .val("")
                .text("请选择")
                .appendTo($(Pian));
            bindAreaDropDownList(Pian, "#Yuan");
            $(Pian).change();
        }

        function getQu(Qu) {
            $(Qu).empty();
            $("<option></option>")
                .val("")
                .text("请选择")
                .appendTo($(Qu));
            bindAreaDropDownList(Qu, "#Pian");
            $(Qu).change();
        }


        function bindAreaDropDownList(id, parentid) {

            if ($(parentid).val() != "") {

                var url = "../Home/GetAreaByParent";
                $.ajaxSetup({ cache: false });
                $.getJSON(url, { id: id.substring(1), parentid: parentid.substring(1), value: $(parentid).val() }, function (data) {
                    if (data == null) {
                        return;
                    }
                    $.each(data, function (i, item) {
                        if (item == null) {
                            return;
                        }
                        $("<option></option>")
                            .val(item["Value"])
                            .text(item["Text"])
                            .appendTo($(id));
                    });
                });
            }
        }


        function deleteselected() {
            var arr = [];
            var count = 0;
            $("input:checked").each(function () {
                if ($(this).attr("id") == undefined) {
                    arr.push($(this).val());
                    count++;
                }

            });
            $.messager.confirm('操作提示', "确认删除这 " + count + " 项吗？", function (r) {
                if (r) {
                    $.post("../Cemetery/Delete", { query: arr.join(",") }, function (res) {
                        if (res == "OK") {
                            //移除删除的数据
                            $.messager.alert('操作提示', '删除成功!', 'info');
                            GetCemeteryString();

                        }
                        else {
                            if (res == "") {
                                $.messager.alert('操作提示', '删除失败!请查看该数据与其他模块下的信息的关联，或联系管理员。', 'info');
                            }
                            else {
                                $.messager.alert('操作提示', res, 'info');
                            }
                        }
                    });
                }
            });

        }
        function GetCemeteryString() {
            $.ajax({
                url: "../Cemetery/GetCemeteryString",
                type: "Post",
                data: { quguid: $('#QuGuid').val() },
                dataType: "json",
                success: function (data) {

                    $('#CemeteryStr').html(data);
                    $("input[ id^='cemetery'][type= 'checkbox']").hide();
                    $("input[type='checkbox']").change(function () {
                        if ($(this).attr("checked")) {
                            if ($(this).attr("checked")) {
                                var entityid = $(this).val();

                                var arr = [];

                                arr.push(entityid);

                                arr.push("^");


                                $.ajax({
                                    url: '../Cemetery/GetFullName',
                                    type: "Post",
                                    data: { rowguid: entityid },
                                    dataType: "text",
                                    success: function (data) {

                                        arr.push(data);
                                        //主键列和显示列之间用 ^ 分割   每一项用 , 分割
                                        if (arr.length > 0) {//一条数据和多于一条
                                            returnParent(arr.join("&")); //每一项用 & 分割
                                        }
                                    }
                                });




                            }
                        }
                    });

 
                   
                        
                    
                    
                }
            });
        }
    </script>
</asp:Content>

